<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>通过阴影弱化背景</title>
    <link rel="stylesheet" href="../public.css">
    <style>
        .box {}

        .overlay {
            /* position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            background: rgba(0, 0, 0, .8); */
        }

        .box div {
            width: 200px;
            height: 200px;
            margin: 20px auto;
            background: yellowgreen;
        }

        .dimmed::before {
            position: fixed;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            z-index: 1;
            background: rgba(0, 0, 0, .8);
        }

        .back {
            /* box-shadow: 0 0 0 999px rgba(0, 0, 0, .8); */
        }
        .back1:backdrop{
            background: rgba(0, 0, 0, .8);
        }
    </style>
</head>

<body>
    <div class="content">
        <h1>通过阴影弱化背景</h1>

        <div class="box overlay">
            <div></div>
        </div>
        <h1>伪元素方案</h1>
        <div class="box dimmed">
            <div></div>
        </div>
        <h1>box-shadow</h1>
        <ul>
            <li>由于遮罩层的尺寸是与视图相关，而不是与页面相关，当滚动页面时，遮罩层的边缘就露出来了</li>
            <li>当使用独立的元素(或伪元素)来实现遮罩层，不仅可以使视觉上把用户的注意力引导到关键元素上；还可以防止用户鼠标与页面的其他部分发生交互。但是box-shadow并不能阻止用户的交互</li>
        </ul>
        <div class="box back">
            <div></div>
        </div>
        <h1>background</h1>
        <ul>
            <li>兼容性不够</li>
        </ul>
        <div class="box back1">
            <div></div>
        </div>
    </div>
</body>

</html>